package miniproj.models.people;

import javax.xml.bind.annotation.*;

public abstract class Person implements java.io.Serializable {

	private static final long serialVersionUID = -7710006838067456973L;

	// Family name
	@XmlAttribute
	protected String lastName;

	@XmlAttribute
	protected String firstName;

	/**
	 * Instantiates a new person. (JavaBeans)
	 */
	public Person() {
		this.lastName = "undefined";
		this.firstName = "undefined";
	}

	/**
	 * Instantiates a new person.
	 * 
	 * @param firstname
	 *            the first name of the person
	 * @param lastname
	 *            the last name of the person
	 */
	public Person(String firstname, String lastname) {
		this.firstName = firstname;
		this.lastName = lastname;
	}

	/**
	 * Gets the first name of this person
	 * 
	 * @return the first name of the person
	 */
	public String getFirstName() {
		return this.firstName;
	}

	/**
	 * Gets the last name of this person
	 * 
	 * @return the last name of the person
	 */
	public String getLastName() {
		return this.lastName;
	}

	@Override
	public boolean equals(Object o) {
		if (!(o instanceof Person))
			return false;

		Person p = (Person) o;

		return (this.lastName.toLowerCase().equals(p.lastName.toLowerCase()) && this.firstName
				.toLowerCase().equals(p.firstName.toLowerCase()));
	}

	public boolean equals(String firstName, String lastName) {
		return (this.firstName.toLowerCase().equals(firstName.toLowerCase()) && this.lastName
				.toLowerCase().equals(lastName.toLowerCase()));
	}

	@Override
	public String toString() {
		return this.firstName + " " + this.lastName;
	}
}
